package com.lord.wand.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lord.wand.entity.User;
import com.lord.wand.service.IUserService;

@RestController
@RequestMapping("/restuser")
public class RestUserController {

	@Autowired
	private IUserService userService;

	@RequestMapping("/list")
	public List<User> list(User model) {
		
		User user=new User();
		user.setUsername("王五");
		user.setPassword("123456");
		userService.add(user);
		
		return userService.getUserList(model);
	}

	@RequestMapping("/detail")
	public User detail(User model) {
		if (model == null || model.getId() == null) {
			model.setId(1);
		}
		return userService.getUserById(model.getId());
	}

}
